package com.ylw.appStart;

import com.ylw.entity.User;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.junit.Before;
import org.junit.Test;

/**
 * 需要在hibernate.cfg.xml里面配置<mapping class="com.ylw.entity.User" />
 * Created by yangliwei on 2017/7/10.
 */
public class AppStart01 {
    Session session = null;

    @Before
    public void before() {
        SessionFactory factory = new Configuration().configure().buildSessionFactory();
        session = factory.openSession();
    }

    @Test
    public void test() {
        User user = new User();
        user.setId(new Long(1));
        user.setName("傻狗a ");
        user.setAddress("china");
        user.setGirlFriend("gao");
        session.save(user);

        session.close();
    }
}
